





export default class RulesSplit{
    constructor(src){

        this.split(src)
    }





    split(src){
      let rules=  src.split(/\n*;\n*/)
        this.rules = new Array();
        if(rules[rules.length-1]==""){
            rules.length=rules.length-1;
        }
       for(let  i=0;i<rules.length;i++){
            let rule=  rules[i].split(/\n*:\n*/);
            let ruleList=rule[1].split('|')

           if(ruleList[0]==""){
               ruleList.shift()
           }
           let ruleLists=new Array();
            for(let n=0;n<ruleList.length;n++){
               let obj= ruleList[n].replace(/^\s+|\s+$/g, '')
                let ws = obj.indexOf("{");

               let zrules=obj.substring(0,ws).split(/\s+/)
                if(zrules[zrules.length-1]==""){
                   zrules.pop();
                }
                zrules.push(obj.substring(ws))
                ruleLists.push(zrules)
            }

           this.rules.push({id:rule[0].replace(/[\r\n ]/g,""),rules:ruleLists})
       }

    }


}